package com.atguigu.lease.common.sms;


import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
@EnableConfigurationProperties(AliyunSMSProperties.class)
@ConditionalOnProperty(prefix = "aliyun.sms",name = "endpoint")
public class AliyunSmsConfiguration {

    @Autowired
    AliyunSMSProperties aliyunSMSProperties;


    @Bean
    public Client smsClient() {
        Config config = new com.aliyun.teaopenapi.models.Config();
        config.setAccessKeyId("LTAI5tEsGciBcsAGmyDyTkwh");
        config.setAccessKeySecret("KmIfZiybKGg4wDUcuu1GgScaWpMFDe");
        config.setEndpoint("dysmsapi.aliyuncs.com");
        try {
            return new Client(config);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }


}
